package com.csweimei.rentmanagementtreasure.enterprise.viewModel;

import android.os.Bundle;

import androidx.annotation.NonNull;
import androidx.databinding.ObservableField;

import com.csweimei.rentmanagementtreasure.base.AppConfig;
import com.csweimei.rentmanagementtreasure.enterprise.act.EntHouseDetailActivity;
import com.csweimei.rentmanagementtreasure.enterprise.act.VipActivity;
import com.csweimei.rentmanagementtreasure.http.entity.BrokerFollowupBean;

import me.goldze.mvvmhabit.base.BaseViewModel;
import me.goldze.mvvmhabit.base.MultiItemViewModel;
import me.goldze.mvvmhabit.binding.command.BindingAction;
import me.goldze.mvvmhabit.binding.command.BindingCommand;
import me.goldze.mvvmhabit.utils.ToastUtils;

public class BFollowItemVM extends MultiItemViewModel {

    public BFollowItemVM(@NonNull BaseViewModel viewModel) {
        super(viewModel);
    }

    public ObservableField<BrokerFollowupBean.DataDTO> bean = new ObservableField<>();

    public void setData(BrokerFollowupBean.DataDTO follow) {
        bean.set(follow);
    }

    public BindingCommand itemClick = new BindingCommand(new BindingAction() {
        @Override
        public void call() {
            if (AppConfig.isEntVip()){
                Bundle bundle = new Bundle();
                bundle.putInt(AppConfig.BUNDLE_KEY,bean.get().getHousingID());
                viewModel.startActivity(EntHouseDetailActivity.class,bundle);
            }else {
                ToastUtils.showShort("您还未开通企业服务，请前往购买相关服务");
                viewModel.startActivity(VipActivity.class);
            }

        }
    });
}
